from django.conf.urls import url
from rest_framework.routers import DefaultRouter

from meiduo_admin.views import admin_user
from meiduo_admin.views import groups
from meiduo_admin.views import orders
from meiduo_admin.views import permission
from meiduo_admin.views import skus
from .views import statistical, users, specs, images
from rest_framework_jwt.views import obtain_jwt_token

urlpatterns = [
    # 登录路由
    url(r'^authorizations/$', obtain_jwt_token),

    # 用户总数统计
    url(r'^statistical/total_count/$', statistical.UserTotalCountView.as_view()),

    # 日增用户统计
    url(r'^statistical/day_increment/$', statistical.UserDayCountView.as_view()),

    # 日活跃用户统计
    url(r'^statistical/day_active/$', statistical.UserActiveCountView.as_view()),

    # 日下单用户量统计
    url(r'^statistical/day_orders/$', statistical.UserOrderCountView.as_view()),

    # 日分类商品访问量月增用户统计
    url(r'^statistical/month_increment/$', statistical.UserMonthCountView.as_view()),

    # 日分类商品访问量
    url(r'^statistical/goods_day_views/$', statistical.GoodsDayView.as_view()),

    # 用户管理
    url(r'^users/$', users.UserView.as_view()),

    # 商品管理--->规格新增id获取
    url(r'^goods/simple/$', specs.SpecsView.as_view({'get': 'simple'})),

    # 商品管理--->图片新增id获取
    url(r'^skus/simple/$', images.ImageView.as_view({'get': 'simple'})),

    # 商品管理--->获取sku的所有三级分类信息
    url(r'^goods/(?P<pk>\d+)/specs/$', skus.SKUView.as_view({'get': 'specs'})),

    # 系统管理--->权限表定义权限类型表操作
    url(r'^permission/content_types/$', permission.PermissionView.as_view({'get': 'content_types'})),

    # 系统管理--->权限表获取所有权限
    url(r'^permission/simple/$', groups.GroupView.as_view({'get': 'simple'})),

    # permission/groups/simple/
    url(r'^permission/groups/simple/$', admin_user.AdminUserView.as_view({'get': 'simple'})),
]

# 商品管理--->规格表管理
router = DefaultRouter()
router.register('goods/specs', specs.SpecsView, base_name='spec')
urlpatterns += router.urls

# 商品管理--->图片表管理
router = DefaultRouter()
router.register('skus/images', images.ImageView, base_name='image')
urlpatterns += router.urls

# 商品管理--->sku表管理
router = DefaultRouter()
router.register('skus', skus.SKUView, base_name='skus')
urlpatterns += router.urls

# 订单管理--->订单表管理
router = DefaultRouter()
router.register('orders', orders.OrderView, base_name='orders')
urlpatterns += router.urls

# 系统管理--->权限表管理
router = DefaultRouter()
router.register('permission/perms', permission.PermissionView, base_name='perms')
urlpatterns += router.urls

# 系统管理--->分组表管理
router = DefaultRouter()
router.register('permission/groups', groups.GroupView, base_name='groups')
urlpatterns += router.urls

# 系统管理--->管理员管理
router = DefaultRouter()
router.register('permission/admins', admin_user.AdminUserView, base_name='admins')
urlpatterns += router.urls
